//
//  Response.h
//  PigMarket
//
//  Created by Felix on 2019/4/11.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, ResultCode) {
    //都是本地定义的结果编码
    ResultCodeLocalHTTPRequestSerializerError = -1001,//HTTP请求序列化错误
    ResultCodeLocalHTTPResponseSerializerError = -1002,//HTTP响应序列化错误
    ResultCodeLocalHTTPURLError = -1003,//网络请求异常
    ResultCodeLocalHTTPStatusError = -1004,//网络响应状态异常
    ResultCodeLocalRequireLogin = -1005, //本地未登录时访问登录认证接口

    ResultCodeLocalForceUpdate = -2001,             // 强制升级
    ResultCodeLocalUnavailable = -2002,             // 版本不可用
    
    // 认证状态码
    ResultCodeSuccess = 0,                          // 响应成功
    ResultCodeAccountError = 1,                     // 账户不存在
    
    ResultCodeInvalidHeqaderParam = 401,            // 401-请求头无效(token,memberId,device,deviceNum)
    ResultCodeDeviceChanged = 402,                  // 402-已更换设备,请重新登录
    ResultCodeParamError = 403,                      // 403-请求参数错误
    ResultCodeAdoptWaittingCheck = 404,             //等待审核
    ResultCodeAdoptNoAgain = 405,                     //请勿再次申请
    ResultCodeSaleTribePig = 407                    //请先预售完该部落下的小猪
};

@interface Response : NSObject

/**
 响应编码
 */
@property(nonatomic, assign) NSInteger code;

/**
 响应码描述
 */
@property(nonatomic, strong) NSString *msg;

/**
 具体业务描述
 */
@property(nonatomic, strong) NSString *desc;

/**
 响应数据
 */
@property(nonatomic, strong) id data;

- (instancetype)initWithCode: (NSInteger) code;

- (instancetype)initWithCode: (NSInteger) code msg:(NSString *)msg;

+ (instancetype)responseWithCode: (NSInteger) code msg:(NSString *)msg;

@end

NS_ASSUME_NONNULL_END
